<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('薪资变动历史')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="modal inmodal fade" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">选择薪资套类型</h4>
            </div>
            <div class="modal-body">
                <p>
                    薪资套：<select id="pgid" name='pgid' class="form-control">
                </select>
                </p>
                <p>
                    生效日期从:
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text" id="Bgdate" class="form-control laydate-demo-2" placeholder="yyyy-MM-dd">
                </div>
                </p>
                <p>
                    生效日期到:
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text" id="EDdate" class="form-control laydate-demo-1" placeholder="yyyy-MM-dd">
                </div>
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" id="missmodal1" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" onclick="getPgid()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>
<button type="button" id="modal1" class="btn btn-primary" data-toggle="modal"
        data-target="#myModal1">选择薪资套
</button>


<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: datetimepicker-js"/>


<script th:inline="javascript">
    var prefix = ctx + "salaryChange/salaryChange";
    var pgid;
    var Bgdate;
    var EDdate;
    var xztList = [];
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        $(".datetimepicker-demo-2").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-2',
                type: 'date'
            });
        });

        $(".datetimepicker-demo-1").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });
        });


        $("#modal1").attr("style", "display:none;");
        getSkypayGroups();
        //queryData();
    });


    /**
     * 获取薪资套列表
     */
    function getSkypayGroups() {
        var html = "";
        $.ajax({
            async: false,
            url: ctx + "salaryCalculation/getSkypayGroups",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#pgid").empty();
                var arry = data;
                for (var i = 0; i < arry.length; i++) {
                    xztList.push({value: arry[i].id, text: arry[i].title});
                    html += "<option value='"
                        + arry[i].id
                        + "'>"
                        + arry[i].title
                        + "</option>";
                }
                $("#pgid").append(html);
                $("#modal1").click();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    function getPgid() {
        pgid = $("#pgid").val();
        Bgdate = $("#Bgdate").val();
        EDdate = $("#EDdate").val();
        $("#missmodal1").click();
        getData();
    }

    function getData() {
        var options = {
            code: "id",
            uniqueId: "id",
            pagination: false,
            url: prefix + "/findDataHistory?pgid=" + pgid + "&Bgdate=" + Bgdate + "&EDdate=" + EDdate,
            height: $(window).height() - 120,
            createUrl: prefix + "/add",
            modalName: "薪资变动历史",
            columns: [
                [
                    {
                        field: 'badge', title: '工号',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'name', title: '姓名',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'compName', title: '公司名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'depName', title: '部门名称',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'jobName', title: '工作岗位',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'empStatusName', title: '员工状态',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'pzidName', title: '薪资区域',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'effectdate', title: '生效日期',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'regtime', title: '登记时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'regbyName', title: '登记人',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'initialized', title: '？确认',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'initializedbyName', title: '确认人',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'initialiZedTime', title: '确认时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'closed', title: '？封存',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'closedByName', title: '封存人',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'closedTime', title: '封存时间',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'remark', title: '备注',
                        rowspan: 2,
                        valign: "middle"
                    },
                ],
                [],
            ]
        };

        //利用ajax动态获取项目
        $.ajax({
            async: false,
            url: ctx + "salaryAdmin/findProObject",
            data: {
                "pgid": pgid
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    var text = data[i].title.replace('（', '').replace("）", '');
                    var stdId = data[i].id;
                    var field = text + "@@@" + stdId;
                    options.columns[0].push({
                        title: data[i].title,
                        rowspan: 1,
                        colspan: 2,
                        align: "center"
                    });
                    options.columns[1].push({
                        title: '原数值',
                        rowspan: 1,
                        field: field + "@@@旧"
                    });
                    options.columns[1].push({
                        title: '数值',
                        rowspan: 1,
                        field: field + "@@@新"
                    });
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
        $.table.init(options);
    }
</script>
</body>
</html>